#include<stdio.h>

int time_money(int time);
double x_money(double x);

int main(){
    double x;
    int time;
    scanf("%lf,%d",&x,&time);
    printf("money=%.0lf",time_money(time) + x_money(x));
    return 0;
}

int time_money(int time){
    if (time < 5 && time >= 0){
        return 0;
    }else if (time >= 5){
        return time / 5 * 2;
    }
}

double x_money(double x){
   if (x <= 3){
       return 10;
    }else if (x > 3 && x <= 10){
        return 10 + (x - 3) * 2;
    }else if (x > 10){
      return 10 + 14 + (x - 10) * 3; 
    }
}
